/**
 * 功能描述
 */

define(function (require, exports, module) {
	var DetailGrid = require("grid");
	 var incomefile = require("../store/incomefile");
	
    var instance = {
        initComponent: function (params, widget) {
        	var detailgrid = new DetailGrid({
        		parentNode : ".J-detailgrid",
        		autoRender: false,
        		model: {
        			url: "api/roomstatistics/querybyroomtypedetails",
//        	        params: function() {
//        	        	var subnav = widget.get("subnav");
//        	        	var rangeDate = subnav.getValue("visitTime");
//        	        	
//        	            return {
//        	            	"startDate":rangeDate.start,
//        	            	"endDate":rangeDate.end,
//        	            	fetchProperties:"employer,destination,memCount,checkinDate,checkoutDate,roomPay,foodPay,healthPay," +
//        	            			"waterPay,electricPay,trafficPay,pickupPay,otherPay,allPay"
//        	            };
//        	        },
        			 id : "detailgrid",
                     allowEdit: false,
                     columns:[{
                    	 name : "employer",
                         label : "组团单位",
                     },{
                    	 name : "destination",
                         label : "目的地",
                     },{
                    	name : "memCount",
                         label : "入住人数", 
                     },{
                    	 name : "checkinDate",
                         label : "入住日期",
                         format:"date"
                     },{
                    	 name : "checkoutDate",
                         label : "退住日期",
                         format:"date"
                     },{
                    	 name : "roomPay",
                         label : "住宿费(元)",
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "foodPay",
                         label : "餐饮费(元)",
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "healthPay",
                         label : "康乐费(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "waterPay",
                         label : "水费(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "electricPay",
                         label : "电费(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "trafficPay",
                         label : "大交通往返费用(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "pickupPay",
                         label : "接送往返费用(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "otherPay",
                         label : "其他费用(元)", 
                         format:function(val){
 							return Number(val).toFixed(2);
 						}
                     },{
                    	 name : "allPay",
                         label : "收入金额(元)", 
                         format:function(val,row){
                        	 
                        	 console.log(row);
        	                 var val = 0;
        	                 val+=(row.roomPay+row.foodPay+row.healthPay+row.waterPay+row.electricPay+row.trafficPay+row.pickupPay+row.otherPay);
        	                 row.allPay = val;
 							 return Number(val).toFixed(2);
 						}
                     }]
        		}
        	});
        	widget.set("detailgrid", detailgrid);
        }
    };
    module.exports = instance;
});
